﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace FloatBall
{
    static class Players
    {
        //Public constants
        public const int MAX_PLAYERS = 8;

        //Public variables and objects
        public static int numActivePlayers;
        public static Player[] player = new Player[MAX_PLAYERS];


        //Private constants
        
        //Private variables and objects
        private static Keys[] upKeys = { Keys.Up, Keys.W, Keys.T, Keys.I, Keys.Up, Keys.W, Keys.T, Keys.I };
        private static Keys[] leftKeys = { Keys.Left, Keys.A, Keys.F, Keys.J, Keys.Left, Keys.A, Keys.F, Keys.J };
        private static Keys[] rightKeys = { Keys.Right, Keys.D, Keys.H, Keys.L, Keys.Right, Keys.D, Keys.H, Keys.L };



        public static void Init()
        {
            numActivePlayers = 2;
            
            for (int n = 0; n < MAX_PLAYERS; n++)
            {
                player[n] = new Player();
            }

            player[0] = new Player(1, new Vector3(200, 100f, 500), true, true);
            player[1] = new Player(1, new Vector3(1400, 100f, 500), false, true);
            player[2] = new Player(1, new Vector3(200, 100f, 300), true, true);
            player[3] = new Player(1, new Vector3(1400, 100f, 300), false, true);
        }


        public static void UpdateAll(KeyboardState keyboard)
        {
            bool up;
            bool left;
            bool right;

            for (int n = 0; n < MAX_PLAYERS; n++)
            {
                if (player[n].isActive)
                {
                    up = keyboard.IsKeyDown(upKeys[n]);
                    left = keyboard.IsKeyDown(leftKeys[n]);
                    right = keyboard.IsKeyDown(rightKeys[n]);

                    player[n].Update(up, left, right);
                }
            }
        
        }

        


    }
}
